home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-19 | 2.1 KB | 68 lines | [TEXT/ToyS] |
- tell application "KnowledgeMiner 3.2"
- activate
-
- -- set start column
- set startindex to index of column "b"
-
- -- set number of columns to calculate
- set noOfColumns to 1
-
- if noOfColumns < 1 then
- set noOfColumns to 1
- end if
-
- repeat with j from startindex to startindex + noOfColumns - 1
- try
- -- set the last row; this works not in all cases, e.g., if the last row is a missing value
- set lastrow to (rowIndex of last cell of column j whose kind is "valuecell")
- try
- set temp to (rowIndex of second cell of column j whose kind is "textcell") - 1
- on error
- set temp to lastrow
- end try
-
- if temp < lastrow then
- set lastrow to temp
- end if
-
- -- or set a fixed value
- --set lastrow to myLastRow
-
- --get the last row of a column that is not empty; used for report
- set reportrow to (rowIndex of last cell of column j whose kind is not "emptycell") + 2
-
- -- read all existing values of a column into the list x
- set x to (value of every cell of column j whose kind is "valuecell" and rowIndex is less than or equal to lastrow)
-
- -- get the dimension of list x
- set n to count x
-
- -- calculate the mean value
- if n > 0 then
- set i to 0
- set mean to 0
- repeat n times
- set i to i + 1
- set u to item i of x
- set mean to u + mean
- end repeat
- set mean to mean / n
- end if
-
- -- fill all missing values of a column with the column mean
- set (value of every cell of column j whose (kind is "emptycell" and rowIndex is less than or equal to lastrow)) to mean
-
- -- report
- set value of cell reportrow of column j to "mean"
- set value of cell (reportrow + 1) of column j to mean
- set value of cell (reportrow + 3) of column j to "# of filled cells"
- set value of cell (reportrow + 4) of column j to (lastrow - n - 1)
- set value of cell (reportrow + 5) of column j to "% filled"
- set value of cell (reportrow + 6) of column j to (100 * (lastrow - n - 1) / (lastrow - 1))
-
- on error -- no missing values are found in column j
- set value of cell (reportrow + 3) of column j to "# of filled cells"
- set value of cell (reportrow + 4) of column j to 0
- end try
- end repeat
- end tell